﻿using Delonix_Regia_Hotel_Management_System.Classes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Delonix_Regia_Hotel_Management_System
{
    public partial class LoginPage : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                lblStatus.Text = "";
            }
        }

        protected void btnLogin_Click(object sender, ImageClickEventArgs e)
        {
            lblStatus.Text = "";

            string username = tbxUsername.Text;
            string password = tbxPassword.Text;

            HotelUser hoteluser = DBManager.LogIn(username, password);

            if (hoteluser != null)
            {
                Session["user"] = hoteluser;

                Response.Redirect("WelcomePage.aspx");
            }
            else
            {
                lblStatus.Text = "Login Failed";
            }
        }
    }
}